package com.myidis.controller;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myidis.entity.Quota;
import com.myidis.response.QuotaRes;
import com.myidis.servlet.QuotaServlet;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/quota")
@Api(tags = "指标相关接口")
public class QuotaController {
	@Autowired
	private QuotaServlet quotaServlet;

	@ResponseBody
	@RequestMapping("/list")
	@ApiOperation("获取所有指标的信息")
	public ArrayList<Quota> list() {
		return quotaServlet.all();
	}
	
	@ResponseBody
	@RequestMapping("/entity")
	@ApiOperation("获取单个指标的信息")
	public Quota one(@RequestBody Quota quota) {
		return quotaServlet.getOne(quota.getId());
	}
	
	@ResponseBody
	@RequestMapping("/add")
	@ApiOperation("添加一个指标")
	public int add(@RequestBody Quota quota) {
		return quotaServlet.insert(quota);
	}
	
	@ResponseBody
	@RequestMapping("/addAll")
	@ApiOperation("添加一组指标")
	public int addAll(@RequestBody  ArrayList<Quota> quotas) {
		return quotaServlet.insertAll(quotas);
	}

	@ResponseBody
	@RequestMapping("/upd")
	@ApiOperation("修改一个指标")
	public int upd(@RequestBody Quota quota) {
		return quotaServlet.update(quota);
	}
	

	@ResponseBody
	@RequestMapping("/del")
	@ApiOperation("删除一个指标")
	public int del(@RequestBody int id) {
		return quotaServlet.delete(id);
	}
	
	@ResponseBody
	@RequestMapping("/delAll")
	@ApiOperation("删除一组指标")
	public int delAll(@RequestBody int[] ids) {
		return quotaServlet.deleteAll(ids);
	}
}